home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / dr2d.lha / apps / DR2DDemoDR2DDemo.c < prev    next >
C/C++ Source or Header  |  1991-11-19  |  2KB  |  75 lines

  1. #include "iffp/obj2d.h"
  2.  
  3. /* This definition has to go somewhere so ReadDR2D can resolve it */
  4. struct Library
  5.     *IFFParseBase;
  6.  
  7. int main( int argc, char **argv )
  8. {
  9.     struct Proj2D
  10.     *Conts;
  11.     int
  12.     Error;
  13.     struct ParseInfo
  14.     PI;
  15.  
  16.     /* Check the argument count */
  17.     if( argc != 3 ) {
  18.     fprintf( stderr, "Usage: %s src dst\n", argv[0] );
  19.     fprintf( stderr, "    src and dst are files or -c for the clipboard\n" );
  20.     return 1;
  21.     }
  22.  
  23.     /* Open iffparse.library */
  24.     IFFParseBase = OpenLibrary( "iffparse.library", 0L );
  25.     if( !IFFParseBase ) {
  26.     fprintf( stderr, "Can't open iffparse.library\n" );
  27.     exit( 1 );
  28.     }
  29.  
  30.     /* Get an IFF handle */
  31.     PI.iff = AllocIFF();
  32.     if( !PI.iff ) {
  33.     fprintf( stderr, "Can't allocate an IFF structure\n" );
  34.     CloseLibrary( IFFParseBase );
  35.     exit( 1 );
  36.     }
  37.  
  38.     /* Open a file for reading */
  39.     Error = openifile( &PI, argv[1], IFFF_READ );
  40.     if( Error ) {
  41.     fprintf( stderr, "Can't open file %s\n", argv[1] );
  42.     CloseLibrary( IFFParseBase );
  43.     exit( 1 );
  44.     }
  45.  
  46.     Error = ReadDR2D( &PI, 0, &Conts );
  47.     closeifile( &PI );
  48.     if( Error != 0 ) {
  49.     fprintf( stderr, "Read Error: %d\n", Error );
  50.     CloseLibrary( IFFParseBase );
  51.     exit( 1 );
  52.     }
  53.  
  54.     Error = openifile( &PI, argv[2], IFFF_WRITE );
  55.     if( Error ) {
  56.     fprintf( stderr, "Can't open file %s\n", argv[2] );
  57.     CloseLibrary( IFFParseBase );
  58.     exit( 1 );
  59.     }
  60.  
  61.     Error = WriteDR2D( &PI, Conts );
  62.     closeifile( &PI );
  63.     if( Error != 0 ) {
  64.     fprintf( stderr, "Write error: %d\n", Error);
  65.     CloseLibrary( IFFParseBase );
  66.     exit( 1 );
  67.     }
  68.  
  69.     FreeConts( Conts );
  70.     CloseLibrary( IFFParseBase );
  71.     exit( 0 );
  72. }
  73.  
  74. /*** EOF test.c ***/
  75.